package com.ruoyi.web.controller.business;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.TbWeightTimeout;
import com.ruoyi.system.service.ITbWeightTimeoutService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 过磅超时Controller
 * 
 * @author ruoyi
 * @date 2024-11-07
 */
@RestController
@RequestMapping("/business/weight-timeout")
public class TbWeightTimeoutController extends BaseController
{
    @Autowired
    private ITbWeightTimeoutService tbWeightTimeoutService;

    /**
     * 查询过磅超时列表
     */
    @GetMapping("/list")
    public TableDataInfo list(TbWeightTimeout tbWeightTimeout)
    {
        startPage();
        List<TbWeightTimeout> list = tbWeightTimeoutService.selectTbWeightTimeoutList(tbWeightTimeout);
        return getDataTable(list);
    }

    /**
     * 导出过磅超时列表
     */
    @Log(title = "过磅超时", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbWeightTimeout tbWeightTimeout)
    {
        List<TbWeightTimeout> list = tbWeightTimeoutService.selectTbWeightTimeoutList(tbWeightTimeout);
        ExcelUtil<TbWeightTimeout> util = new ExcelUtil<TbWeightTimeout>(TbWeightTimeout.class);
        util.exportExcel(response, list, "过磅超时数据");
    }

    /**
     * 获取过磅超时详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tbWeightTimeoutService.selectTbWeightTimeoutById(id));
    }

    /**
     * 新增过磅超时
     */
    @Log(title = "过磅超时", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbWeightTimeout tbWeightTimeout)
    {
        return toAjax(tbWeightTimeoutService.insertTbWeightTimeout(tbWeightTimeout));
    }

    /**
     * 修改过磅超时
     */
    @Log(title = "过磅超时", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbWeightTimeout tbWeightTimeout)
    {
        return toAjax(tbWeightTimeoutService.updateTbWeightTimeout(tbWeightTimeout));
    }

    /**
     * 删除过磅超时
     */
    @Log(title = "过磅超时", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tbWeightTimeoutService.deleteTbWeightTimeoutByIds(ids));
    }
}
